*Package required for producing tables: "outreg2"
ssc install outreg2

*Please set the working directory to the folder where the readme.txt file is located
cd "xxx/xxx/xxx"

* Load college survey dataset
use "data/collegesurvey.dta", clear

gen treatcvorg = treat_cv
replace treat_cv = 1 if treat_cv_po == 1 

gen treatpoorg = treat_po
replace treat_po = 1 if treat_cv_po == 1


* Standardize variables
egen scsapproval = std(sc_legit)
egen distrust = std(op_takeother)
egen distrustexp = std(op_takeself)
egen propaganda = std(scinfo_state)
egen femalestd = std(female)
egen agestd = std(age)
egen incomestd = std(faminc)
egen ccpstd = std(party_status)
egen mediastd = std(media_phone)
egen behaviorstd = std(behavior)
egen servicestd = std(par_org)
egen scoreselfstd = std(sc_selfscore)
egen commentstd = std(par_comment)
egen petitionstd = std(exp_authority)
egen treatcvstd = std(treat_cv)
egen treatpostd = std(treat_po)
egen treatcvpostd = std(treat_cv_po)

* generate a variable indicating state media as the only source of information about the SCS
gen scinfostateonly = scinfo_state
replace scinfostateonly = 0 if scinfo_nonstate == 1


*------------------Table B.1 Information Revelation and Support for the SCS: Experimental Evidence--------------------
reg sc_legit treat_cv treat_po treat_cv_po i.univ, r
	outreg2 using "outputapp/uexpcontrol.xls", replace dec(3)

reg sc_legit treat_cv treat_po treat_cv_po i.univ if scinfostateonly == 1, r
	outreg2 using "outputapp/uexpcontrol.xls", dec(3)

reg sc_legit treat_cv treat_po treat_cv_po i.univ if scinfostateonly == 0, r
	outreg2 using "outputapp/uexpcontrol.xls", dec(3)

reg sc_legit treat_cv treat_po treat_cv_po ///
    propaganda distrust distrustexp age female faminc party_status ///
    behavior par_org i.univ, r
	outreg2 using "outputapp/uexpcontrol.xls", dec(3)

reg sc_legit treat_cv treat_po treat_cv_po ///
    distrust distrustexp age female faminc party_status ///
    behavior par_org i.univ if scinfostateonly == 1, r
	outreg2 using "outputapp/uexpcontrol.xls", dec(3)

reg sc_legit treat_cv treat_po treat_cv_po ///
    distrust distrustexp age female faminc party_status ///
    behavior par_org i.univ if scinfostateonly == 0, r
	outreg2 using "outputapp/uexpcontrol.xls", dec(3)


*------------------Table B.2 Information Revelation and Support for Government Managing the SCS--------------------
probit sc_gov treat_cv treat_po treat_cv_po i.univ, r
	outreg2 using "outputapp/uexpgovt.xls", replace dec(3)
probit sc_gov treat_cv treat_po treat_cv_po i.univ if scinfostateonly == 1, r
	outreg2 using "outputapp/uexpgovt.xls", dec(3)
probit sc_gov treat_cv treat_po treat_cv_po i.univ if scinfostateonly == 0, r
	outreg2 using "outputapp/uexpgovt.xls", dec(3)	
probit sc_gov treat_cv treat_po treat_cv_po ///
    scinfo_state op_takeother op_takeself age female faminc party_status ///
    behavior par_org i.univ, r
	outreg2 using "outputapp/uexpgovt.xls", dec(3)
probit sc_gov treat_cv treat_po treat_cv_po ///
    op_takeother op_takeself age female faminc party_status ///
    behavior par_org i.univ if scinfostateonly == 1, r
	outreg2 using "outputapp/uexpgovt.xls", dec(3)
probit sc_gov treat_cv treat_po treat_cv_po ///
    op_takeother op_takeself age female faminc party_status ///
    behavior par_org i.univ if scinfostateonly == 0, r
	outreg2 using "outputapp/uexpgovt.xls", dec(3)



*------------------Table B.3 Group Mean Comparisons with Two-Sample T-Tests--------------------
gen treatcv = treatcvorg
replace treatcv = . if treat_cv_po == 1 | treatpoorg == 1

gen treatpo = treatpoorg
replace treatpo = . if treat_cv_po == 1 | treatcvorg == 1

gen treatcvttl = treatcvorg
replace treatcvttl = 1 if treat_cv_po == 1

gen treatpottl = treatpoorg
replace treatpottl = 1 if treat_cv_po == 1

* T-test
ttest sc_legit, by(treatcv)
ttest sc_legit, by(treatpo)
ttest sc_legit, by(treatcvttl)
ttest sc_legit, by(treatpottl)



*------------------Table B.4 Information Control and Support for the SCS: College Field Survey--------------------
reg scsapproval propaganda distrust distrustexp agestd femalestd incomestd ccpstd ///
    behaviorstd servicestd i.univ, cluster(univ) r
	outreg2 using "outputapp/usurveyoutput.xls", replace dec(3)
reg scsapproval propaganda distrust distrustexp agestd femalestd incomestd ccpstd ///
    behaviorstd servicestd scoreselfstd i.univ, cluster(univ) r
	outreg2 using "outputapp/usurveyoutput.xls", dec(3)
reg scsapproval propaganda distrust distrustexp agestd femalestd incomestd ccpstd ///
    behaviorstd servicestd scoreselfstd commentstd i.univ, cluster(univ) r
	outreg2 using "outputapp/usurveyoutput.xls", dec(3)
reg scsapproval propaganda distrust distrustexp agestd femalestd incomestd ccpstd ///
    behaviorstd servicestd scoreselfstd commentstd petitionstd i.univ, cluster(univ) r
	outreg2 using "outputapp/usurveyoutput.xls", dec(3)



* Load nationwide survey dataset
use "data/nationwidesurvey.dta", clear

* generate a variable of SCS selfscore, remove N/A entries
gen selfscore = score_vs_family
replace selfscore = . if selfscore > 5

* generate variable female
gen female = 1-gender

* Standardize variables
egen scsapproval = std(credit_systems_approval)
egen distrust = std(are_chinese_distrusting)
egen isolation = std(lower_friends)
egen infocontrol = std(infotvnews)
egen propaganda = std(infotvnews)
egen genderstd = std(gender)
egen agestd = std(age1)
egen incomestd = std(income)
egen ccpstd = std(ccp_memberdm)
egen pubemploystd = std(pubemploy)
egen pilotstd = std(living_in_pilot_city)
egen influencestd = std(credit_decision_influence)
egen gtruststd = std(government_confidence)
egen fairstd = std(credit_score_fairness)
egen edustd = std(education)
egen cityruralstd = std(city_rural)
egen privacyusestd = std(privacyuse)
egen femalestd = std(female)
egen selfscorestd = std(selfscore)


*------------------Table B.5 Information Control and Support for the SCS: Nationwide Online Survey--------------------

reg scsapproval propaganda isolation distrust agestd edustd femalestd incomestd ///
    pubemploystd pilotstd cityruralstd ccpstd i.region2, cluster(region) r
	outreg2 using "outputapp/nsurveyoutput.xls", replace dec(3)
reg scsapproval propaganda isolation distrust agestd edustd femalestd incomestd ///
    pubemploystd pilotstd cityruralstd ccpstd fairstd i.region2, cluster(region) r
	outreg2 using "outputapp/nsurveyoutput.xls", dec(3)
reg scsapproval propaganda isolation distrust agestd edustd femalestd incomestd ///
    pubemploystd pilotstd cityruralstd ccpstd privacyusestd i.region2, cluster(region) r
	outreg2 using "outputapp/nsurveyoutput.xls", dec(3)
reg scsapproval propaganda isolation distrust agestd edustd femalestd incomestd ///
    pubemploystd pilotstd cityruralstd ccpstd selfscorestd i.region2, cluster(region) r
	outreg2 using "outputapp/nsurveyoutput.xls", dec(3)
reg scsapproval propaganda isolation distrust agestd edustd femalestd incomestd ///
    pubemploystd pilotstd cityruralstd ccpstd fairstd privacyusestd selfscorestd ///
	i.region2, cluster(region) r
	outreg2 using "outputapp/nsurveyoutput.xls", dec(3)
